import { request } from "@/utils"
import {ResType} from '@/apis/response_type'

//封装返回的单挑
export type ChannelItem ={
    id :string,
    name:string,
}

//封装返回的data
export type Channels = {
    channels :ChannelItem[]
}

//封装请求方式
export function fetchChannlesListAPI(){
    return request.get<ResType<Channels>>('/channels') 
}


//响应数据类型
export type ListItem = {
    art_id: string
    title: string
    aut_id: string
    comm_count: number
    pubdate: string
    aut_name: string
    is_top: 0 | 1
    cover: {
      type: 0 | 1 | 3
      images: string[]
    }
  }

export type ListRes={
    results:ListItem[],
    pre_timestamp:string, //请求下一页数据的时间戳
}

// 请求数据类型
export type ListParams = {
    channel_id: string
    timestamp: string
  }


//获取列表数据
export function fetchListAPI(params: ListParams) {
    return request.get<ResType<ListRes>>('/articles',{params})
  }